package com.clkj.xiuzheng.dao;

import com.clkj.xiuzheng.pojo.CustomerVisit;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

/**
 * @author yawang
 * @create 2024/04/18 14:14:57
 **/
@Repository
public interface CustomerVisitMapper extends Mapper<CustomerVisit> {

    @Select("select a.*,b.customer_name,b.customer_shopName,b.customer_img,b.customer_tel,b.customer_sex,b.customer_address,b.customer_note from t_cl_customerVisit a left join t_cl_customer b on a.customer_id = b.customer_id " +
            "where a.user_id = #{userId} and dateDiff(day,a.visit_date,getDate()) <=7 ")
    List<CustomerVisit> listCustomerVisitBySeven(@Param("userId")Integer userId);

    @Select("select count(*) from t_cl_customerVisit  where user_id = #{userId} and DateDiff(day,visit_date,getDate())<=1")
    Integer getTodayVisit(Integer userId);

    @Select("select count(*) from t_cl_customerVisit  where user_id = #{userId} and DateDiff(day,visit_date,getDate())<=30")
    Integer getMonthVisit(Integer userId);
}
